package com.hutao.manage.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hutao.manage.component.Config;
import com.hutao.manage.pojo.HospitalNoteVersion;
import com.hutao.manage.service.HospitalNoteVersionService;
import com.hutao.manage.util.ExceptionUtil;
import com.hutao.manage.util.JsonUtils;
import com.hutao.manage.util.Result;
import com.hutao.manage.util.StringUtil;

@RequestMapping("/hospitalNoteVersion")
@Controller
public class HospitalNoteVersionController {
	private Logger log = LoggerFactory.getLogger(HospitalNoteVersionController.class);
	
	@Autowired
	private HospitalNoteVersionService hospitalNoteVersionService;
	
	@Autowired  
    private Config conf;  
	
	@PostMapping("/findHopitalNoteVersionListByFirstGuid")
	@ResponseBody
	public Result findHopitalNoteVersionListByFirstGuid(String firstGuid) {
		
		try {
			Map<String, Object> results = hospitalNoteVersionService.findHopitalNoteVersionListByFirstGuid(firstGuid);
			return new Result(true, "查询成功!", results);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("---------查询病案历史版本异常-----------" + ExceptionUtil.getStackTrace(e));
			return new Result(false, "系统异常!");
		}
	}
	
	
//	@GetMapping("/findHospitalNoteVersionByGuid")
//	@ResponseBody
//	public Result findHospitalNoteVersionByGuid(String guid) {
//		try {
//			Map<String, Object> results = new HashMap<>();
//			List<String> newPicUrlList = null;
//			HospitalNoteVersion hospitalNoteVersion = hospitalNoteVersionService.findHospitalNoteVersionByGuid(guid);
//			
//			if (hospitalNoteVersion != null && StringUtil.isNotBlank(hospitalNoteVersion.getPicUrlListJson())) {
//				String picUrlStr = hospitalNoteVersion.getPicUrlListJson();
//			    List<String> picUrlList = JsonUtils.jsonToList(picUrlStr, String.class);
//			   
//			    if (picUrlList != null && picUrlList.size() > 0) {
//			    	newPicUrlList = new ArrayList<>();
//			    	
//				   for(String picUrlStr1 : picUrlList) {
//					   newPicUrlList.add(conf.getHospitalizationNoteResourceUrl() + picUrlStr1);
//				   }
//			    }
//			}
//			
//			results.put("picUrlList", newPicUrlList);
//			
//			return new Result(true, "查询成功!", results);
//		} catch (Exception e) {
//			e.printStackTrace();
//			log.error("---------查询某份病案历史版本异常-----------" + ExceptionUtil.getStackTrace(e));
//			
//			return new Result(false, "系统异常!");
//		}
//	}
//	
	
	
	
	
	

}
